//
// Wrap.cpp for Wrap in /home/bissin_g//projets/piscine/rush2/Wrap
//
// Made by guillaume bissinger
// Login   <bissin_g@epitech.net>
//
// Started on  Sat Jan 19 15:34:23 2013 guillaume bissinger
// Last update Sat Jan 19 22:34:09 2013 olivier mercher
//

#include	"../general.hh"

Wrap::Wrap() : Object(), m_isOpen(true), _ptr(NULL)
{
}

Wrap::Wrap(Wrap const &k) : Object(), m_isOpen(k.m_isOpen), _ptr(k._ptr)
{
}

Wrap::~Wrap()
{
}

Wrap&		Wrap::operator=(Wrap const &k)
{
  if (&k != this)
    {
      this->m_isOpen = k.m_isOpen;
      this->_ptr = k._ptr;
    }
  return *this;
}

bool		Wrap::isOpen()
{
  return (this->m_isOpen);
}

void		Wrap::openMe()
{
  if (m_isOpen == true)
    std::cerr << "It's already open you idiot !" << std::endl;
  this->m_isOpen = true;
}

void		Wrap::closeMe()
{
  if (m_isOpen == false)
    std::cerr << "It's already close you idiot !" << std::endl;
  this->m_isOpen = false;
}

std::string const	&Wrap::getName() const
{
}

std::string const	&Wrap::getTitle() const
{
}

Object		*Wrap::wrapMeThat(Object *k)
{
  if (k == NULL)
    {
        std::cerr << "What the hell is that ? this thing doesn't exit ! (NULL)" << std::endl;
	return this;
    }
  if (this->_ptr)
    {
      std::cerr << "This wrap is full" << std::endl;
      return this;
    }
  if (this->_type == BOX && this->isOpen())
    {
      if (k->_type == GIFTPAPER || (k->_type == BOX && !(k->isOpen())))
	{
	  std::cerr <<  "You can't wrap that... You dumbass !" << std::endl;
	  return this;
	}
      this->_ptr = k;
      return this;
    }
  else if (this->_type == BOX && !this->isOpen())
    {
      std::cerr << "This box is closed, you must open it before put something in it, you moron !" << std::endl;
      return this;
    }
  if (this->_type == GIFTPAPER)
    {
      if (k->_type == GIFTPAPER || (k->_type == BOX && (k->isOpen())))
	{
	  std::cerr <<  "You can't wrap that... You dumbass !" << std::endl;
	  return this;
	}
      this->_ptr = k;
      return this;
    }
  std::cerr << "It a toy don't abuse it !" << std::endl;
  return this;
}
